//package com.xuelang.pipeline.app.resource.impl;
//
//import com.netflix.hystrix.exception.HystrixBadRequestException;
//import com.netflix.hystrix.exception.HystrixRuntimeException;
//import com.netflix.hystrix.exception.HystrixTimeoutException;
//import com.xuelang.pipeline.app.resource.TektonService;
//import com.xuelang.pipeline.app.resource.request.PipelineCrdRequest;
//import com.xuelang.pipeline.app.resource.request.PipelineRunCrdRequest;
//import com.xuelang.pipeline.app.resource.v1beta.pipeline.V1Beta1Pipeline;
//import com.xuelang.pipeline.client.common.result.ApiResult;
//import feign.hystrix.FallbackFactory;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.stereotype.Service;
//
//import java.util.List;
//
///**
// * @author liuyuan.ly
// * @since 2024/6/25 19:09
// */
//@Service
//@Slf4j
//public class TektonServiceFallbackImpl implements FallbackFactory<TektonService> {
//
//
//    @Override
//    public TektonService create(Throwable throwable) {
//        String fallReason = throwable.getMessage();
//        if (throwable instanceof HystrixTimeoutException) {
//            fallReason = "Socket connect timeout.";
//        } else if (throwable instanceof HystrixBadRequestException) {
//            fallReason = "Bad Request.";
//        } else if (throwable instanceof HystrixRuntimeException) {
//            fallReason = "Runtime exception";
//        }
//
//        final String returnFallReason = fallReason;
//
//        log.error("调用fegin数据接口失败。接口名称:{}；失败原因:{}", this.getClass().getName(), fallReason);
//        return new TektonService() {
//
//            ApiResult apiResult = ApiResult.fail("worker返回异常：" + returnFallReason);
//
//            @Override
//            public ApiResult<Boolean> createPipeline(PipelineCrdRequest dto) {
//                return apiResult;
//            }
//
//            @Override
//            public ApiResult<List<V1Beta1Pipeline>> getPipelineList(PipelineCrdRequest dto) {
//                return apiResult;
//            }
//
//            @Override
//            public ApiResult<Boolean> createPipelineRun(PipelineRunCrdRequest dto) {
//                return apiResult;
//            }
//
//            @Override
//            public ApiResult<String> getPipelineRunList(PipelineRunCrdRequest dto) {
//                return apiResult;
//            }
//
//
//        };
//    }
//}
